// 例子8

var myPromise =  new Promise(function(resolve, reject) {
    var random = Math.random();
    if (random >= 0.5) {
            resolve('访问成功！');
    } else {
            reject('访问失败！');
    }
});

myPromise.then(function (value) {
    console.log(value);
    return value;
}).catch(function (err) {
    console.log(err);
    return err;
}).finally(function () {
    console.log('over!');
});